#define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
using namespace std;
class Solution {
public:
    vector<vector<int> > rotateMatrix(vector<vector<int> >& mat, int n)
    {
        for (int i = 0;i < mat.size();++i)
        {
            for (int j = 0;j < i;++j)
            {
                swap(mat[i][j], mat[j][i]);
            }
        }
        for (int i = 0;i < mat.size();++i)
        {
            int left = 0, right = mat[0].size() - 1;
            while (left < right)
            {
                swap(mat[i][left], mat[i][right]);
                ++left;
                --right;
            }
        }
        return mat;
    }
};